/**
* Copyright 2009 Waag Society <http://www.waag.org>
* This file is part of Annotrax.
*
* Annotrax is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* Annotrax is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Annotrax.
* If not, see http://www.gnu.org/licenses/gpl.html
*/

/**
as we get if from the server plus some prototype functions
*/
self.Annotation = function()
{
	//new
	this.duration = 0;  //int
	this.time = 0; //int
	this.movieId = null; //int
	this.keywords = null; //array
	this.comment = null; //bool
	this.channelId = null; //int
	this.channel = null; //ref
}
Annotation.prototype.getEndTime = function()
{
	return (AnnotraxTime.stringToInt(this.time) + AnnotraxTime.stringToInt(this.duration)) 
}
Annotation.prototype.getBeginTime = function()
{
	return (AnnotraxTime.stringToInt(this.time)) 
}
Annotation.prototype.toText = function(truncate_len)
{
	text = ""
	
	if(this.keywords) 
	{
		for(var i=0;i<this.keywords.length;i++)
		{
			text += this.keywords[i].name
			text += " "
		}
	}
	if(this.comment)
	{
		text += this.comment
	}
	
	if(truncate_len)
	{
		if(text.length > truncate_len)
		{
			text = text.substr(0,truncate_len) + "..."
		}
	}
	
	return text
}
/**
as we get if from the server plus some prototype functions
*/
self.Movie = function()
{
	//new
	this.filename = null;
	this.duration = null;
}	
Movie.prototype.getSrcUrl = function()
{
	url = document.location.protocol + "//" + document.location.hostname + "/movies/" + this.filename;
	return url;
}
/**
extend the channel objects from the server with this prototype functions
*/
self.Channel = function()
{
	this.color = null;
	this.name = null;
}	
Channel.prototype.getColor = function()
{
	if(this.color == null)
	{
		this.color = NameToColor(this.name)
	}
	return this.color;
}




